﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class CreatFramDataFile : EditorWindow {

    static string writePath = "/maps/";
    static GameObject selectObj;


    [MenuItem("Excel解析/生成渔场数据表")]
    static void ByWindow()
    {
        CreatFramDataFile window = EditorWindow.GetWindow<CreatFramDataFile>();
    }

    private void OnGUI()
    {
        GUILayout.Label("设置渔场数据生成路径");
        writePath = GUILayout.TextField(writePath);
        GUILayout.Label("请选择一个合法的WaypointManager的物体");

        if (GUILayout.Button("生成C#渔场数据"))
        {
            Debug.Log("生成C#协议文件----------");
            if (selectObj != null)
            {
                CreatFarmConfigUitl.CreatFarmFile(selectObj, writePath);
            }

        }

        if (Selection.activeGameObject != null)
        {
            string path = Selection.activeGameObject.name;
            if (Selection.activeGameObject.GetComponent<SWS.WaypointManager>())
            {
                selectObj = Selection.activeGameObject;
                GUILayout.Label(path);

            }
        }
    }

    private void OnSelectionChange()
    {
        Repaint();
    }



}
